package com.dfbz.demo01;

import java.util.Arrays;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01 {


    public static void main(String[] args) {

        int[] arr1 = {23, 543, 54, 6};
        int[] arr2 = {23, 543, 54, 6};

        System.out.println(arr1 == arr2);           // false
        System.out.println(Arrays.equals(arr1,arr2));

    }

    public static void test4(String[] args) {
        int[] arr = {23, 543, 54, 6, 457, 56, 756};

//        int[] newArr = Arrays.copyOf(arr, 3);
//        System.out.println(Arrays.toString(newArr));


        int[] newArr = Arrays.copyOfRange(arr, 2, 4);

        System.out.println(Arrays.toString(newArr));

    }
    public static void test3(String[] args) {
        int[] arr = {23, 543, 54, 6, 457, 56, 756};

        System.out.println(Arrays.binarySearch(arr,6));         // 3
        System.out.println(Arrays.binarySearch(arr,56));         // 5

        Arrays.sort(arr);           //      [6, 23, 54, 56, 457, 543, 756]

        System.out.println(Arrays.toString(arr));
        System.out.println(Arrays.binarySearch(arr,78));

    }
    public static void test2() {
        int[] arr = {23, 543, 54, 6, 457, 56, 756};
//        Arrays.sort(arr);
//        System.out.println(Arrays.toString(arr));           // [6, 23, 54, 56, 457, 543, 756]

        Arrays.sort(arr,2,4);
        System.out.println(Arrays.toString(arr));

    }
    public static void test1(String[] args) {

        int[] arr = {23, 543, 54, 6, 457, 56, 756};
        String arrStr = Arrays.toString(arr);           //  [23, 543, 54, 6, 457, 56, 756]
        System.out.println(arrStr);
    }
}
